<template>
    <div class="my">
        <div class="header-box">
            <div class="top-box">
                <i class="set" @click="goPerson"></i>
                <p @click="goLogin">{{ userStore.$state.token ? "退出登录" : "登录" }}</p>
                <!-- <i class="fx"></i> -->
            </div>
            <div class="headshot-box">
                <div class="headshot" @click="goPerson">
                    <img :src="userStore.$state.user_avator" alt="" />
                </div>
                <p class="user-name">{{ userStore.$state.user_nick_name }}</p>
                <p class="directives">潮流就是我的态度</p>
                <p class="vip"><span class="lv">普通</span><span>成长值0</span></p>
            </div>
        </div>
        <div class="section-box">
            <div class="mylike">
                <div class="likes" @click="goMyLike">
                    <p class="num">{{ likeLength }}</p>
                    <p class="likes-title">商品收藏</p>
                </div>
                <div class="likes" @click="goMyLook">
                    <p class="num">{{ lookLength }}</p>
                    <p class="likes-title">浏览记录</p>
                </div>
                <div class="likes" @click="goAddress">
                    <p class="num">{{ length }}</p>
                    <p class="likes-title">地址管理</p>
                </div>
            </div>
            <div class="myorder">
                <div class="top-box">
                    <p class="top-title">我的订单</p>
                    <p class="top-all" @click="goOrder">全部订单</p>
                </div>
                <div class="order-con">
                    <div class="content">
                        <i class="dfk"></i>
                        <p>待付款</p>
                    </div>
                    <div class="content">
                        <i class="dfh"></i>
                        <p>待发货</p>
                    </div>
                    <div class="content">
                        <i class="dsh"></i>
                        <p>待付款</p>
                    </div>
                </div>
            </div>
            <div class="mypurse">
                <div class="top-box">
                    <p class="top-title">我的钱包</p>
                    <p class="top-all">查看全部</p>
                </div>
                <div class="purse-con">
                    <div class="purse">
                        <p class="purse-num">0</p>
                        <p class="purse-title">资产</p>
                    </div>
                    <div class="purse">
                        <p class="purse-num">0</p>
                        <p class="purse-title">优惠卷</p>
                    </div>
                    <div class="purse">
                        <p class="purse-num">0</p>
                        <p class="purse-title">红包</p>
                    </div>
                    <div class="purse">
                        <p class="purse-num">0</p>
                        <p class="purse-title">有货币</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { getLook } from "../../api/index";
import { useStore } from "../../store/index";
import { useUserInfo } from "../../store/user";
import { useRouter, useRoute } from "vue-router";
import { showToast } from "vant";

let router = useRouter();
let route = useRoute();
const $store = useStore();
const userStore = useUserInfo();

let length = $store.$state.addrLength;

let likeLength = $store.$state.likelength;

let lookLength = userStore.lookLength;

const goOrder = () => router.push({ name: "myorder" });

const goAddress = () => router.push({ name: "address" });

const goMyLook = () => router.push({ name: "mylook" });

const goMyLike = () => router.push({ name: "mylike" });

const goPerson = () => router.push({ name: "person" });

const goLogin = () => {
    showToast("退出登录");
    router.push({ name: "login" });
    localStorage.removeItem("auto_token");
    localStorage.removeItem("user_info");
    userStore.getInfo({});
};
</script>

<style lang="scss" scoped>
.my {
    background: #f2f2f2;
    width: 100%;
    // height: 1000px;
    padding-bottom: 100px;
}
.header-box {
    position: relative;
    padding: 10px 10px 0;
    width: 100%;
    height: 175px;
    background: #313131;

    .top-box {
        display: flex;
        justify-content: space-between;
        i {
            display: block;
            width: 30px;
            height: 30px;
            background-repeat: no-repeat;
            background-size: 100%;
        }
        .set {
            background-image: url(@/assets/set.png);
        }
        .fx {
            background-image: url(@/assets/fx.png);
        }
        p {
            color: #fff;
            font-size: 14px;
        }
    }
    .headshot-box {
        position: absolute;
        bottom: -35px;
        left: 35.5px;
        margin: 0 auto;
        background: #fff;
        width: 80%;
        height: 125px;
        border-radius: 10px;

        .headshot {
            position: absolute;
            top: -30%;
            left: 50%;
            transform: translateX(-50%);
            padding: 3px;
            background: #fff;
            border-radius: 50%;
            width: 80px;
            height: 80px;
            img {
                border-radius: 50%;
                width: 100%;
                height: 100%;
            }
        }

        .directives,
        .user-name {
            margin-top: 45px;
            font-size: 16px;
            color: #000;
            text-align: center;
        }
        .directives {
            margin-top: 5px;
            font-size: 14px;
            color: #393939;
        }
        .vip {
            text-align: center;
            font-size: 12px;
            margin-top: 10px;
            color: #999;
        }
        .lv {
            color: #313131;
            background: #999;
            padding: 2px 5px;
            border-radius: 5px;
            margin-right: 5px;
        }
    }
}
.section-box {
    // border: 1px solid #000;
    margin-top: 50px;
    padding: 0 10px;

    .top-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .top-title {
        font-size: 16px;
        color: #313131;
        font-weight: bold;
    }
    .top-all {
        position: relative;
        font-size: 12px;
        color: #999;
        padding-right: 7px;

        &::after {
            position: absolute;
            top: 5px;
            right: 0;
            transform: rotate(45deg);
            content: "";
            display: block;
            width: 5px;
            height: 5px;
            border: 1px solid #999;
            border-left-color: transparent;
            border-bottom-color: transparent;
        }
    }

    .mylike {
        padding: 15px 0;
        border-radius: 5px;
        background: #fff;
        width: 100%;
        display: flex;
        .likes {
            flex-grow: 1;
            text-align: center;
        }
        .likes-title {
            padding-top: 5px;
            font-size: 13px;
            color: #999;
        }
    }
    .myorder {
        width: 100%;
        margin-top: 10px;
        padding: 10px 10px;
        border-radius: 5px;
        background: #fff;

        .order-con {
            width: 100%;
            padding: 10px 0;
            display: flex;
        }
        .content {
            flex-grow: 1;
            text-align: center;

            i {
                margin: 0 auto;
                display: block;
                width: 30px;
                height: 30px;
                background-repeat: no-repeat;
                background-size: 100%;
            }

            .dfk {
                background-image: url(@/assets/dfk.png);
            }
            .dfh {
                background-image: url(@/assets/dfh.png);
            }
            .dsh {
                background-image: url(@/assets/dsh.png);
            }

            p {
                font-size: 14px;
                color: #999;
            }
        }
    }

    .mypurse {
        width: 100%;
        margin-top: 10px;
        padding: 10px 10px;
        border-radius: 5px;
        background: #fff;

        .purse-con {
            padding: 15px 0;
            display: flex;

            .purse {
                flex-grow: 1;
                text-align: center;
            }
        }
        .purse-title {
            padding-top: 5px;
            font-size: 14px;
            color: #999;
        }
    }
}
</style>
